Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Persist querystrings in mapbox:// resource urls to API requests #6182

Merged
merged 1 commit into from
Sep 16, 2016

Conversation

jakepruitt
Copy link

Carries over any query strings from mapbox://-prefixed styles urls, source urls and tile urls to the api.mapbox.com requests.

cc/ @mapsam @1ec5 @jfirebaugh @yhahn @GretaCB

@mention-bot
Copy link

@jakepruitt, thanks for your PR! By analyzing this pull request, we identified @jfirebaugh, @yhahn and @1ec5 to be potential reviewers.

@@ -44,7 +44,13 @@ std::string normalizeSourceURL(const std::string& url, const std::string& access
throw std::runtime_error("You must provide a Mapbox API access token for Mapbox tile sources");
}

return baseURL + "v4/" + url.substr(protocol.length()) + ".json?access_token=" + accessToken + "&secure";
auto queryIdx = url.find("?");
std::string query = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omit = "" -- it'll be initialized to an empty string automatically.

std::string query;
if (queryIdx != std::string::npos) {
query = url.substr(queryIdx + 1, url.length() - queryIdx + 1);
if (query.length() > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally if (!query.empty()) { is better practice since it is faster than query.size().

@springmeyer
Copy link
Contributor

Made a refactoring pass and rebased this /cc @jakepruitt. Ready for review by others, notably @jfirebaugh @1ec5

@@ -11,15 +11,16 @@ namespace util {
namespace mapbox {

const std::string protocol = "mapbox://";
const std::size_t protocol_length = protocol.length();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Camel case please.

Carries over any query strings from mapbox://-prefixed styles urls,
source urls and tile urls to the api.mapbox.com requests.
@jfirebaugh jfirebaugh merged commit d169ea5 into master Sep 16, 2016
@jfirebaugh jfirebaugh deleted the keep-queries branch September 16, 2016 21:11
@mapsam
Copy link
Contributor

mapsam commented Sep 19, 2016

Thank you @jfirebaugh!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants